!
function(t) {
	function e(t, e, i) {
		if (-1 != t.indexOf("?")) {
			var n = new RegExp("(\\?|&" + e + ")=[^&]*");
			t = n.test(t) ? t.replace(n, "$1=" + i) : t + "&" + e + "=" + i
		} else t = t + "?" + e + "=" + i;
		return t
	}
	function i(t, i) {
		for (var n in i) t = e(t, encodeURIComponent(n), encodeURIComponent(i[n]));
		return t
	}
	function n() {
		return o || (o = this.init.apply(this, arguments))
	}
	function s(t, e, i) {
		t = parseInt(t, 10), e = parseInt(e, 10);
		var n = p["default"];
		"inner" == i.opts.curenv ? (0 == t && (n = p["char"]), 1 == t && 1 == e && (n = p.click), 1 == t && 4 == e && (n = p.click), 1 == t && 7 == e && (n = p.click), 1 == t && 8 == e && (n = p.slide), 1 == t && 9 == e && (n = p.slidepuzzle)) : (1 == t && (n = p["char"]), 2 == t && 1 == e && (n = p.click), 2 == t && 4 == e && (n = p.click), 2 == t && 7 == e && (n = p.click), 2 == t && 8 == e && (n = p.slide), 2 == t && 9 == e && (n = p.slidepuzzle));
		var s = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,
			o = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
		i.sizeSC.width = n.width + "px", i.sizeSC.height = n.height + "px", o - n.height < 0 ? i.posSC.top = "0px" : i.posSC.top = (o - n.height) / 2 + "px", i.posSC.left = (s - n.width) / 2 + "px"
	}
	var o, r = {
		securityCode: "securityCode"
	},
		c = function(t, e) {
			return t.currentStyle ? t.currentStyle[e] : document.defaultView.getComputedStyle(t, !1)[e]
		},
		h = function(t) {
			return function(e) {
				return Object.prototype.toString.call(e) == "[object " + t + "]"
			}
		},
		d = h("Object"),
		u = h("Function"),
		a = function(t, e) {
			if (t && e) {
				if (d(e)) {
					for (var i in e) t.style[i] = e[i];
					return e
				}
				return c(t, e)
			}
		},
		l = function(t, e, i) {
			i = i || !1;
			var n = {};
			for (var s in e) t[s] = e[s];
			if (i) {
				for (var s in t) n[s] = t[s];
				return n
			}
			return t
		},
		p = {
			"char": {
				width: 302,
				height: 222
			},
			click: {
				width: 295,
				height: 320
			},
			slide: {
				width: 295,
				height: 295
			},
			slidepuzzle: {
				width: 295,
				height: 262
			},
			"default": {
				width: "100%",
				height: "100%"
			}
		},
		f = {
			top: "0%",
			left: "0%"
		},
		m = {
			ele: document.body,
			src: "",
			uid: "",
			capcd: "",
			startFn: function() {},
			endFn: function() {}
		},
		g = function(t) {
			var e = window.document.getElementsByTagName("script")[0],
				n = window.document.createElement("script"),
				s = t.callback || "callback",
				o = "_aq_" + Math.floor(1e6 * Math.random()),
				r = window[o] = t.success ||
			function() {}, c = t.url, h = {};
			h[s] = o, t.data && (h = l(h, t.data)), c = i(c, h), n.async = t.async || !0, n.src = c, n.onload = function() {
				n && e.parentNode && e.parentNode.removeChild(n), r = null
			}, e.parentNode.insertBefore(n, e)
		};
	n.prototype = {
		init: function(t) {
			return this.opts = l(m, t || {}), this.initOptions(), this.listenFunc = [], this.msg = new Messenger("parent"), this.initListener(), this.windowHeight = 0, this.windowWidth = 0, this
		},
		initOptions: function() {
			this.ele = this.opts.ele ? this.opts.ele == document ? document.body : this.opts.ele : document.body, this.src = "/qlogin/captcha.php" + this.opts.params + "&do=" + this.opts.cgi, this.ticket = "", this.randstr = "", this.sizeSC = l({}, p["default"]), this.posSC = l({}, f), this.securityIframe = "", this.startY = 0, this.moveY = 0
		},
		initListener: function() {
			var t = this;
			this.msg.listen(function(e) {
				try {
					e = JSON.parse(e)
				} catch (i) {
					throw new Error('The data needs to be like "JSON.stringify({message: xxx})"!')
				}
				if (e && e.message && e.message.type) {
					e = e.message;
					var n = e.type;
					switch (n) {
					case 3:
						if (e && e.ticket) {
							t.ticket = e.ticket, t.randstr = e.randstr;
							for (var s = 0, o = t.listenFunc.length; o > s; s++) t.closeSecurityCode(function() {
								t.listenFunc[s]({
									ret: 0,
									ticket: e.ticket,
									randstr: e.randstr
								})
							});
							t.listenFunc.length || t.closeSecurityCode()
						}
						return;
					case 4:
						for (var s = 0, o = t.listenFunc.length; o > s; s++) t.closeSecurityCode(function() {
							t.listenFunc[s]({
								ret: 1
							})
						});
						return void(t.listenFunc.length || t.closeSecurityCode());
					case 6:
						return void t.closeSecurityCode()
					}
				}
			})
		},
		initPos: function(t) {
			t && t.top && (this.posSC.top = t.top), t && t.left && (this.posSC.left = t.left)
		},
		create: function() {
			if ("popup" == this.opts.type) {
				var t, e = this,
					i = this.opts.gettype;
				g({
					url: i,
					success: function(i) {
						n = i.capclass, t = i.subcapclass, s(i.capclass, i.subcapclass, e), e.src = e.opts.domain + "/" + i.src + e.opts.params, e.createSecurityCode();
						var n = parseInt(i.capclass, 10);
						window.onresize = function() {
							s(n, t, e);
							var i = {
								height: e.sizeSC.height,
								width: e.sizeSC.width,
								top: e.posSC.top,
								left: e.posSC.left
							};
							a(e.securityIframe, i), ("inner" == e.opts.curenv && 0 == n || "outer" == e.opts.curenv && 1 == n) && e.send2securityCode(JSON.stringify({
								message: {
									type: 1,
									width: window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,
									height: window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
								}
							}))
						}
					}
				})
			} else {
				var n = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
					o = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
				this.sizeSC.height = n + "px", this.sizeSC.width = o + "px", this.windowHeight = n, this.windowWidth = o, this.createSecurityCode();
				var e = this;
				window.onresize = function() {
					var t = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
						i = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
					if (!(Math.abs(e.windowWidth - i) < 30)) {
						e.sizeSC.height = t + "px", e.sizeSC.width = i + "px", e.windowHeight = t, e.windowWidth = i;
						var n = {
							height: e.sizeSC.height,
							width: e.sizeSC.width
						};
						a(e.securityIframe, n)
					}
				}
			}
		},
		createSecurityCode: function() {
			this.opts.startFn();
			var t = {
				uid: this.opts.uid,
				cap_cd: this.opts.capcd,
				rnd: Math.floor(1e6 * Math.random())
			};
			if (this.hasSecurityCode()) {
				var e = {
					height: this.sizeSC.height,
					width: this.sizeSC.width,
					top: this.posSC.top,
					left: this.posSC.left
				};
				return a(this.securityIframe, e), void(this.securityIframe.src = i(this.src, t))
			}
			var n = document.createElement("iframe");
			n.setAttribute("frameborder", "0", 0), n.setAttribute("border", "0"), n.marginheight = 0, n.marginwidth = 0, n.setAttribute("marginheight", "0", 0), n.setAttribute("marginwidth", "0", 0);
			var s = "absolute";
			"popup" == this.opts.type && (s = "absolute");
			var e = {
				height: this.sizeSC.height,
				width: this.sizeSC.width,
				top: this.posSC.top,
				left: this.posSC.left,
				position: s,
				margin: "auto",
				border: "0px",
				"z-index": 999
			};
			a(n, e), this.securityIframe = n, this.ele.appendChild(n), this.src = i(this.src, t), n.src = this.src, this.initSecurityCodeTarget()
		},
		hasSecurityCode: function() {
			var t = this.securityIframe ? this.securityIframe : !1;
			return t
		},
		initSecurityCodeTarget: function() {
			this.msg.addTarget(this.securityIframe.contentWindow, r.securityCode)
		},
		destroy: function() {
			o && (this.closeSecurityCode(), this.listenFunc = [], this.msg.clear(), this.ele = "", o = "")
		},
		refresh: function(t) {
			o && (this.closeSecurityCode(), this.initOptions(), d(t) && (t.uin && (this.opts.uid = t.uin), t.uid && (this.opts.uid = t.uid), t.capcd && (this.opts.capcd = t.capcd)), this.createSecurityCode())
		},
		listen: function(t) {
			this.listenFunc.push(t)
		},
		send2securityCode: function(t) {
			var e = r.securityCode;
			this.msg.targets[e].send(t)
		},
		closeSecurityCode: function(t) {
			this.opts.endFn(), this.securityIframe && (this.securityIframe.parentNode && this.securityIframe.parentNode.removeChild(this.securityIframe), this.securityIframe = ""), u(t) && t(), window.CollectGarbage && window.CollectGarbage()
		},
		clear: function() {
			this.listenFunc.length = 0
		},
		getTicket: function() {
			return {
				ticket: this.ticket,
				randstr: this.randstr
			}
		},
		start: function(t) {
			this.opts.startFn = t
		},
		end: function(t) {
			this.opts.endFn = t
		}
	}, t.AqSCode = n
}(window);